# coding:utf-8
import pandas as pd
from sklearn.model_selection  import train_test_split
from sklearn.linear_model import LinearRegression

data_source = pd.read_excel("波士顿房价.xlsx")
inputs = data_source[["LSTAT"]].values
outputs = data_source["MEDV"].values
(train_inputs, test_inputs, train_outputs, test_outputs) = train_test_split(inputs, outputs, train_size=0.8, test_size=0.2)

model = LinearRegression()
model.fit(train_inputs, train_outputs)
print(model.score(train_inputs, train_outputs))
print(model.score(test_inputs, test_outputs))

